FROM golang:1.17 AS backend

WORKDIR /go/src/app
COPY ./http-server.go .
COPY ./go.mod .
ENV GO111MODULE on
ENV GOPROXY https://goproxy.cn

RUN go mod tidy && go build http-server.go


FROM ubuntu:latest
ENV DEBIAN_FRONTEND noninteractive
RUN mkdir -p /opt/bin
COPY --from=backend /go/src/app/http-server /opt/bin

# # backend port
EXPOSE 8000

# start backend
# ENTRYPOINT [ "/bin/bash", "-l", "-c" ]
CMD ["/opt/bin/http-server"]